<?php
session_start();
if (!isset($_SESSION["email"])) {
    header('Location: login.php');
}else{
  if ($_SESSION["email"]!="programming.iter@gmail.com") {
     header('Location: login.php');
  }
}
?>
<?php
include("../../lib/connection.php");
//Add new

//Update
if(isset($_POST["btn_update"])){
	$id = $_POST["member_id"];
	$level = $_POST["level"];
	$email = $_POST["email"];
	$name = $_POST["name"];
	$status = $_POST["status"];
	$sql = "UPDATE member 
			SET level = $level,
				email = '$email',
				name = '$name',
				status = $status,
				upd_date = NOW()
			WHERE id = $id";
	mysqli_query($conn,$sql);
	header("Location: ../quan-ly-thanh-vien.php?member_id=$id");
}
//Delete
if (isset($_GET["member_id"])) {
	$id = $_GET["member_id"];
	$sql = "DELETE FROM member WHERE id=$id";
	mysqli_query($conn,$sql);
	header("Location: ../quan-ly-thanh-vien.php");
}

